package com.ruoyi.system.controller;

import java.util.List;
import java.io.IOException;
import javax.servlet.http.HttpServletResponse;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.PostMapping;
import org.springframework.web.bind.annotation.PutMapping;
import org.springframework.web.bind.annotation.DeleteMapping;
import org.springframework.web.bind.annotation.PathVariable;
import org.springframework.web.bind.annotation.RequestBody;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;
import com.ruoyi.common.log.annotation.Log;
import com.ruoyi.common.log.enums.BusinessType;
import com.ruoyi.common.security.annotation.RequiresPermissions;
import com.ruoyi.system.domain.DataModelType;
import com.ruoyi.system.service.IDataModelTypeService;
import com.ruoyi.common.core.web.controller.BaseController;
import com.ruoyi.common.core.web.domain.AjaxResult;
import com.ruoyi.common.core.utils.poi.ExcelUtil;
import com.ruoyi.common.core.web.page.TableDataInfo;

/**
 * 模型类别管理Controller
 * 
 * @author ruoyi
 * @date 2024-11-13
 */
@RestController
@RequestMapping("/model_type")
public class DataModelTypeController extends BaseController
{
    @Autowired
    private IDataModelTypeService dataModelTypeService;

    /**
     * 查询模型类别管理列表
     */
    @RequiresPermissions("system:model_type:list")
    @GetMapping("/list")
    public TableDataInfo list(DataModelType dataModelType)
    {
        startPage();
        List<DataModelType> list = dataModelTypeService.selectDataModelTypeList(dataModelType);
        return getDataTable(list);
    }

    /**
     * 导出模型类别管理列表
     */
    @RequiresPermissions("system:model_type:export")
    @Log(title = "模型类别管理", businessType = BusinessType.EXPORT)
    @PostMapping("/export")
    public void export(HttpServletResponse response, DataModelType dataModelType)
    {
        List<DataModelType> list = dataModelTypeService.selectDataModelTypeList(dataModelType);
        ExcelUtil<DataModelType> util = new ExcelUtil<DataModelType>(DataModelType.class);
        util.exportExcel(response, list, "模型类别管理数据");
    }

    /**
     * 获取模型类别管理详细信息
     */
    @RequiresPermissions("system:model_type:query")
    @GetMapping(value = "/{modelTypeId}")
    public AjaxResult getInfo(@PathVariable("modelTypeId") Long modelTypeId)
    {
        return success(dataModelTypeService.selectDataModelTypeByModelTypeId(modelTypeId));
    }

    /**
     * 新增模型类别管理
     */
    @RequiresPermissions("system:model_type:add")
    @Log(title = "模型类别管理", businessType = BusinessType.INSERT)
    @PostMapping
    public AjaxResult add(@RequestBody DataModelType dataModelType)
    {
        return toAjax(dataModelTypeService.insertDataModelType(dataModelType));
    }

    /**
     * 修改模型类别管理
     */
    @RequiresPermissions("system:model_type:edit")
    @Log(title = "模型类别管理", businessType = BusinessType.UPDATE)
    @PutMapping
    public AjaxResult edit(@RequestBody DataModelType dataModelType)
    {
        return toAjax(dataModelTypeService.updateDataModelType(dataModelType));
    }

    /**
     * 删除模型类别管理
     */
    @RequiresPermissions("system:model_type:remove")
    @Log(title = "模型类别管理", businessType = BusinessType.DELETE)
	@DeleteMapping("/{modelTypeIds}")
    public AjaxResult remove(@PathVariable Long[] modelTypeIds)
    {
        return toAjax(dataModelTypeService.deleteDataModelTypeByModelTypeIds(modelTypeIds));
    }
}
